package com.sc.nft.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.sc.nft.enums.UpdateAddrOperationTypeEnums;
import com.sc.nft.sup.SuperEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * @author JYT
 * @create 2024/6/11 14:52
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("sc_mall_order_update_address_log")
public class MallOrderUpdateAddressLog  extends SuperEntity implements Serializable {
    /**
     * 订单id
     */
    private Long orderId;
    /**
     * 操作方式 0用户操作，1,客服操作
     */
    private UpdateAddrOperationTypeEnums OperationType;
    /**
     * 修改前地址
     */
    private String beforeAddr;
    /**
     * 修改后地址
     */
    private String afterAddr;

    public static MallOrderUpdateAddressLog build(MallOrder mallOrder,MallDeliveryAddress mallDeliveryAddress,UpdateAddrOperationTypeEnums operationTypeEnums){
        MallOrderUpdateAddressLog mallOrderUpdateAddressLog = new MallOrderUpdateAddressLog();
        mallOrderUpdateAddressLog.setOrderId(mallOrder.getId());
        mallOrderUpdateAddressLog.setOperationType(operationTypeEnums);
        mallOrderUpdateAddressLog.setBeforeAddr(mallOrder.getUserRealName() + mallOrder.getUserTel() + mallOrder.getProvince() + mallOrder.getCity() + mallOrder.getArea() + mallOrder.getUserAddress());
        mallOrderUpdateAddressLog.setAfterAddr(mallDeliveryAddress.getRecipientName() + mallDeliveryAddress.getContactNumber() + mallDeliveryAddress.getState() + mallDeliveryAddress.getCity() + mallDeliveryAddress.getArea() + mallDeliveryAddress.getDetailedAddress());
        return mallOrderUpdateAddressLog;
    }
}
